//
//  HeaderView.m
//  renmingongshe
//
//  Created by macbook on 2017/11/3.
//  Copyright © 2017年 xiaodian. All rights reserved.
//

#import "HeaderView.h"

@implementation HeaderView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithReuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 50)];
        view.backgroundColor = [UIColor whiteColor];
        
        _btn = [[UIButton alloc]initWithFrame:CGRectMake(10, 15, 20, 20)];
        
        //        if ([_editArr[section]boolValue]) {
        //            btn.enabled = NO;
        //        }else{
        //            btn.enabled = YES;
        //        }
        
        [_btn setImage:[UIImage imageNamed:@"Login_disagree"] forState:UIControlStateNormal];
        [_btn setImage:[UIImage imageNamed:@"Login_agree"] forState:UIControlStateSelected];
        [_btn addTarget:self action:@selector(chooseClick:) forControlEvents:UIControlEventTouchUpInside];
        [view addSubview:_btn];
        
        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, view.height-0.5, WIDTH, 0.5)];
        line.backgroundColor = [UIColor lightGrayColor];
        [view addSubview:line];
        
        _shopName = [[UILabel alloc]initWithFrame:CGRectMake(_btn.right+10, 15, WIDTH-_btn.right-10-60, 20)];
        _shopName.font = [UIFont boldSystemFontOfSize:14];
        [view addSubview:_shopName];
        
        _btn1 = [[UIButton alloc]initWithFrame:CGRectMake(WIDTH-60, 15, 50, 20)];
        _btn1.titleLabel.textAlignment = NSTextAlignmentRight;
        [_btn1 setTitle:@"编辑" forState:UIControlStateNormal];
        [_btn1 setTitle:@"完成" forState:UIControlStateSelected];
        [_btn1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _btn1.titleLabel.font = [UIFont systemFontOfSize:12];
        [_btn1 addTarget:self action:@selector(editClick:) forControlEvents:UIControlEventTouchUpInside];
        [view addSubview: _btn1];
        
        [self addSubview:view];
    }
    
    return self;
}

- (void)chooseClick:(UIButton *)btn
{
    self.chooseClick(btn);
}
- (void)editClick:(UIButton*)btn
{
    self.editClick(btn);
}
@end
